import { defineStore } from "pinia";

/** 用户数据 */
export const useUserStore = defineStore("user", {
  state: () => {
    return {
      userInfo: "",
      role: "",
      token: "",
    };
  },
  getters: {},
  actions: {
    setUser(userInfo) {
      this.userInfo = userInfo;
    },
    setRole(role) {
      this.role = role;
    },
    setToken(token) {
      this.token = token;
    },
  },
  persist: {
    enabled: true,
    strategies: [
      {
        storage: window.localStorage,
      },
    ],
  },
});
